package com.gouwudai.gobbs.service.impl;

import org.extremecomponents.table.limit.Limit;

import com.gouwudai.gobbs.common.Constants;
import com.gouwudai.gobbs.common.IPageList;
import com.gouwudai.gobbs.dao.IAdDAO;
import com.gouwudai.gobbs.pojo.TbbsAd;
import com.gouwudai.gobbs.service.IAdService;
import com.litt.core.common.PageParam;
import com.litt.core.util.ExtremeTableUtil;

public class AdServiceImpl implements IAdService
{
	IAdDAO adDAO;
		
	public void save(TbbsAd tbbsAd)
	{	
		adDAO.save(tbbsAd);
	}

	public TbbsAd load(Integer id)
	{
		return (TbbsAd)adDAO.load(id);
	}

	public void update(TbbsAd tbbsAd)
	{
		adDAO.update(tbbsAd);
	}

	public void delete(Integer Id)
	{		
			adDAO.delete(Id);
	}
	
	public IPageList listPage(PageParam pageParam)
	{        
        return adDAO.listPage(pageParam);
	}
	
	public void AutoBindingTable(javax.servlet.http.HttpServletRequest request)
	{
		Limit limit = ExtremeTableUtil.getLimit(request, Constants.DEFAULT_PAGE_SIZE);
		IPageList page = this.listPage(new PageParam(limit.getPage(),limit.getCurrentRowsDisplayed(),ExtremeTableUtil.getSort(limit)));
		request.setAttribute("resultList",page.getRsList());
		request.setAttribute("totalRows",page.getTotalSize());
	}

	public void setAdDAO(IAdDAO adDAO) {
		this.adDAO = adDAO;
	}


}